package com.ybkj.daijia.server.service;

import com.ybkj.daijia.chart.TableOrderMonthVo;
import com.ybkj.daijia.common.CompanyOrderVo;
import com.ybkj.daijia.common.DriverOrderDetailVo;
import com.ybkj.daijia.common.DriverOrderVo;
import com.ybkj.daijia.common.MemberOrderVo;
import com.ybkj.daijia.common.OrderFromSourceVo;
import com.ybkj.daijia.common.PageVo;
import com.ybkj.daijia.common.Result;
import com.ybkj.daijia.page.Page;
import com.ybkj.daijia.server.mc.Passenger;
import com.ybkj.daijia.server.mc.PassengerAddress;
import com.ybkj.daijia.server.mc.PassengerConcats;
import com.ybkj.daijia.server.model.ChartDay;
import com.ybkj.daijia.server.model.ChartMonth;
import com.ybkj.daijia.server.model.ChartYear;
import com.ybkj.daijia.server.model.Driver;
import com.ybkj.daijia.server.model.Rate;
import com.ybkj.daijia.server.sales.Coupon;
import com.ybkj.daijia.server.zhuan.Car;
import com.ybkj.daijia.server.zhuan.CarType;
import com.ybkj.daijia.server.zhuan.CarTypeCompany;
import com.ybkj.daijia.server.zhuan.Insurance;
import com.ybkj.daijia.server.zhuan.Order;
import com.ybkj.daijia.server.zhuan.Order.PayTypeDetails;
import com.ybkj.daijia.server.zhuan.OrderOrbit;
import com.ybkj.daijia.server.zhuan.OrderTemp;
import com.ybkj.daijia.server.zhuan.PayRecordOrder;
import com.ybkj.daijia.server.zhuan.ServiceType;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpSession;

public interface ZhuancheService {

    Page<Order> queryZhuanOrder(Long companyId, String orderNo, Long employId,
        String employName, String employPhone, String passengerName,
        String passengerPhone, String carNumber, Integer status);

    List<Order> queryByEmployId(Long employId, String status);

    Result<Order> createOrder(Long passengerId, String passengerName,
        String passengerPhone, String showPhone, Long companyId,
        String companyName, Long carTypeId, String startAddress,
        String startAddressDetail, Double startLat, Double startLng,
        String endAddress, String endAddressDetail, Double endLat,
        Double endLng, Date serverTime, Double budgetPay,
        Double startPrice, Double mileagePrice, Double runTimePrice,
        Integer travelTime, Double mileage, Long employId,
        String channelName, Long couponId, String operator);

    Result<Order> cancelOrder(Order order, String cancelCause, String operator,
        String who);

    Order findOne(Long id);

    Order tempToForever(Long id, PayTypeDetails prePayType, Coupon coupon);

    void remark(Long id, String memo);

    void review(Long id, String content, Double score);

    Result<Order> paidan(Driver driver, Order order, String operator);

    /**
     * 更改司机状态, 更改订单状态
     * @param driver
     * @param order
     * @return
     */
    Result<Order> autoPaidan(Driver driver, Order order);

    Long countBusyAmount(Long id);

    Result<Order> callback(Long id, String cause);

    List<PassengerConcats> findPassengerConcats(Long passengerId);

    PassengerAddress findPassengerToPlace(Long passengerId, Integer type);

    Result<Order> completeTask(Order order);

    List<Order> selectCuidan();

    void closeCuidan(Long orderId);

    List<CarType> queryCarTypes(Long companyId);

    List<CarType> queryCarTypeV4up(Long companyId);

    int deleteCarType(Long id);

    int deleteCar(Long id);

    Map<String, Object> createCarType(String name, Integer sequence,
        String picture, String ifTaxi, String accessibleType);

    int updateCarType(Long id, String name, Integer sequence, Long areaId,
        String picture);

    Page<Car> queryCars(Long companyId, Long carTypeId, String carNumber,
        String employName, Integer status);

    Map<String, Object> createCar(Car car) throws ParseException;

    List<Car> queryByInsuranceTime();

    Long queryByInsuranceTimeLong();

    List<Car> queryByOverhaulTime();

    Long queryByOverhaulTimeLong();

    Car findCar(Long id);

    Map<String, Object> updateCar(Car car);

    CarType findCarType(Long carTypeId);

    List<Car> findByCarTypeId(Long carTypeId);

    Map<String, Object> getPrice(Long areaId, Long distance, Long time);

    List<Order> listNewOrders();

    List<Car> findCarsByNumber(String carNumber, Long companyId);

    List<Order> findActivedOrdersByDriver(Long driverId);

    Long countActivedOrdersByDriver(Long driverId);

    ChartYear dataForYear(Integer year, Long companyId);

    ChartMonth zhuancheDataForMonth(Integer year, Integer month, Long companyId);

    List<TableOrderMonthVo> tableOrderMonth(Integer year, Long companyId);

    // 预算价格
    Map<String, Object> getNewPrice(Long areaId, Double distance, Long time);

    Page<Map<String, Object>> orderListData(String orderNumber,
        String clientPhone, String driverPhone, String companyName,
        String createOrderName, String startTime, String endTime,
        String allorderType, String allstatus, Integer page, Integer rows,
        String treatment, String startFinishTime, String endFinishTime)
        throws ParseException;

    List<Map<String, Object>> orderListDataExport(HttpSession session,
        String orderNumber, String clientPhone, String driverPhone,
        String companyName, String createOrderName, String startTime,
        String endTime, String allorderType, String allstatus,
        String treatment, String startFinishTime, String endFinishTime)
        throws ParseException;

    ChartDay zhuancheDataForDay(Integer year, Integer month, Integer day,
        Long companyId);

    PageVo<OrderFromSourceVo> orderFromSource(Date start, Date end,
        Long companyId);

    List<Order> findMonthOrder(Integer year, Integer month);

    PageVo<MemberOrderVo> zhuanMemberOrder(Date startTime, Date endTime,
        Long companyId, Long gradeId, Integer type);

    PageVo<DriverOrderVo> zhuancheIntroduce(Long companyId, Date start, Date end);

    PageVo<CompanyOrderVo> companyOrder(Date start, Date end);

    OrderTemp findOneTemp(Long orderId);

    Result<Order> completeTaskNewV3(Order order, Passenger passenger, Driver driver,
        String completeType, String payType, BigDecimal hasPayed, boolean adminHandle);

    Result<Order> confirmTask(Order order, String xml);

    Result<PayRecordOrder> createPayRecordOrder(PayRecordOrder payRecordOrder);

    PayRecordOrder findOnePayRecordOrder(Long id);

    Result<PayRecordOrder> payRecordOrderTreatment(PayRecordOrder payRecordOrder);

    Page<Car> queryByParamsCars(String companyName, String carType,
        String carNumber, String employName, String allstatus);

    Result<Order> fillOrder(Order order, Driver driver, CarType carType);

    Page<CarType> queryByCompanyCarTypes(String companyName);

    PageVo<DriverOrderDetailVo> driverOrderDetail(Long driverId, Date start, Date end);

    PageVo<DriverOrderDetailVo> driverOrderDetail2(Long driverId, Date start, Date end);

    void updateCarStatus(Long carId, Integer i);

    OrderOrbit findOrbitByOrderId(Long id);

    void acceptInfoFee(Driver driver, Order order);

    long countFinishedByPassengerAndFinishTime(Long passengerId,
        String orderFromSources, Date startDate, Date endDate);

    long countActiveByPassenger(Long passengerId);

    Page<Order> findByDriverAndFinishTime(Long employId, Date begin, Date end,
        Integer page, Integer limit);

    Map<String, Object> findRate(Long driverid, Integer page, Integer limit);

    Rate findRateOne(Long id);

    void deleteRateOne(Long id);

    Result<Order> updateRealMoney(Order order, BigDecimal couponMoney,
        BigDecimal cashMoney, BigDecimal signMoney,
        BigDecimal balanceMoney, BigDecimal alipayMoney,
        BigDecimal weixinMoney, BigDecimal driverMoney,
        BigDecimal memberMoney, BigDecimal wxMoney, String content);

    List<Order> findOrderFinishedBycompanyId(Long companyId, Date start,
        Date end);

    /***
     * 获取快车状态为5的订单, 即到达目的地, 但是还没有支付
     * @param passengerId
     * @return
     */
    long countNotPayByPassenger(Long passengerId);

    long countNotFinishedByPassenger(Long passengerId);

    long countTodayOrderByPassenger(Long passengerId);

    // 满足金额大于lowestMoney的完成订单
    List<Order> findReward(Long driverId, BigDecimal lowestMoney, Date start,
        Date end);

    // Map<String, Object> createCarTypeV4up(
    // Long companyId, String companyName, String name, Integer sequence, String
    // picture, Long tangzuAreaId,Long rizuAreaId,
    // Long banrizuAreaId, Long jiejiAreaId,Long songjiAreaId, Long
    // jiezhanAreaId,Long songzhanAreaId,
    // String tangzuAreaName, String rizuAreaName, String banrizuAreaName,
    // String jiejiAreaName, String songjiAreaName,
    // String jiezhanAreaName, String songzhanAreaName);

    Map<String, Object> updateCarTypeV4up(Long id, String name,
        Integer sequence, String picture, String ifTaxi,
        String accessibleType);

    Map<String, Object> deleteCarTypeV4up(Long id);

    List<OrderTemp> queryByGroupId(Long groupId);

    Order tempToForeverV4up(Long id, PayTypeDetails prePayType, Coupon coupon);

    ServiceType queryServiceType(Long carTypeId, Long companyId,
        String serviceTypeStr);

    Result<List<Order>> createOrderV4up(Long passengerId, String passengerName,
        String passengerPhone, Long companyId, String companyName,
        String startAddress, String startAddressDetail, Double startLat,
        Double startLng, String endAddress, String endAddressDetail,
        Double endLat, Double endLng, Date serverDate, String carTypes,
        String couponIds, String channelName, String operator,
        String serviceType, String memo, String flightNo, String trainNo,
        Integer travelTime, Double mileage, String createOrderName, Integer bookStatus,
        BigDecimal makePrice, Integer isMakePrice);

    Page<Car> queryByParamsCarsV4up(Long companyId, String companyName,
        String carType, String carNumber, String employName, String status, String isPlatforms);

    Map<String, Object> startCarTypeCompany(Long carTypeId, Long companyId,
        String companyName, Long tangzuAreaId, Long rizuAreaId,
        Long banrizuAreaId, Long jiejiAreaId, Long songjiAreaId,
        Long jiezhanAreaId, Long songzhanAreaId, String tangzuAreaName,
        String rizuAreaName, String banrizuAreaName, String jiejiAreaName,
        String songjiAreaName, String jiezhanAreaName,
        String songzhanAreaName);

    Page<CarType> queryCarTypeV4up();

    Page<CarTypeCompany> queryCarTypeCompany(Long carTypeId, String companyName, Long companyId);

    Map<String, Object> updateCarTypeCompany(Long carTypeId, Long companyId,
        String companyName, Long tangzuAreaId, Long rizuAreaId,
        Long banrizuAreaId, Long jiejiAreaId, Long songjiAreaId,
        Long jiezhanAreaId, Long songzhanAreaId, String tangzuAreaName,
        String rizuAreaName, String banrizuAreaName, String jiejiAreaName,
        String songjiAreaName, String jiezhanAreaName,
        String songzhanAreaName);

    Map<String, Object> deleteCarTypeCompany(Long carTypeCompanyId);

    Car queryCarByNumber(String carNumber);

    Map<String, Object> updateCar(Long carId, Long companyId,
        String companyName, String carName, String carNumber,
        Long carTypeId, Integer status, Double drivingDistance,
        String buyTime, Long employId, String employName,
        Integer limitLine, String insuranceTime, String overhaulTime);

    Result<Order> confirmTaskV4(Order order, Driver driver);

    PageVo<DriverOrderDetailVo> driverOrderDetailCount(Long driverId,
        Date start, Date end);

    Result<Map<String, Object>> batchCreate(String data);

    Car getCarByNumberAndFlights(String carNumber, String flights);

    List<com.ybkj.daijia.server.zhuan.CarTypeRel> findCarTypeRelByCarTypeId(
        Long carTypeId);

    CarType getCarTypeByTypeName(String typeName);

    List<CarType> getCarTypeByIftaxi(String ifTaxi);

    List<Order> findByDriverId(Long driverId, Integer status);

    Map<String, Object> createInsurance(Insurance insurance);

    Page<Insurance> queryInsuranceByPage(Long carId);

    void deletetInsurance(Long id);

    Map<String, Object> upCarInfo(Long[] ids, String basePath);

    Map<String, Object> countOnDutyByDriver(Long id, Date lastTime, Date end);

    /**
     * 修改车辆上传状态
     *
     * @param id
     */
    void updateUpStatus(Long id);

    Page<Car> findCarByIds(Long[] ids, Integer page, Integer limit);

    Result<Order> autoCallback(Order order, Driver driver);

    /**
     * 查询不能接预约订单的司机
     *
     * @return
     */
    Set<String> findBookDrivers();

    /**
     * 查询所有订单都不能接的司机
     *
     * @return
     */
    Set<String> findBusyBookDrivers();

    /**
     * 查询当前司机是否处于忙碌状态
     *
     * @param employId
     * @return
     */
    Boolean findDriverBusy(Long employId, Integer isBook, Long orderId);

}